<%@page import="models.BestOfSiteOptions"%>
<%@page import="java.text.SimpleDateFormat, java.util.Date, java.util.*"%>
<%@page import="com.googlecode.objectify.Objectify, com.googlecode.objectify.ObjectifyService, com.googlecode.objectify.Query" %>

<%@ page import="java.util.Date;import java.util.Calendar;"%>

<%

	Date today = new java.util.Date();
	Date _dtImplemented = today;
	SimpleDateFormat formatNowYear = new SimpleDateFormat("yyyy");
	SimpleDateFormat formatNowMonth = new SimpleDateFormat("MMMMM");
	String sYear = formatNowYear.format( _dtImplemented);
	String sMonth = formatNowMonth.format(_dtImplemented);
	
	Objectify ofy = ObjectifyService.begin();
	
    Calendar cal = Calendar.getInstance();
    int month = cal.get(Calendar.MONTH);
	
%>

<form name="frmnomination">
<b>Your Site Nomination: </b>
<table align="center" cellspacing="0" cellpadding="0" border="1" summary="">
	<tbody>
		<tr>
			<td style="text-align:left">
				Select Month:  
				<select name="nommonth">

					<% 
						Query<BestOfSiteOptions> qqq = ofy.query(BestOfSiteOptions.class).order("Quarter");
						if( qqq.countAll() > 0 ){
							
							HashSet <String>hh = new HashSet <String>();
							Iterator iterator;
							String temp = "";							
							for ( BestOfSiteOptions f : qqq.fetch() ) {
								hh.add(f.getMonth());
							}
							
							iterator = hh.iterator(); 
							while (iterator.hasNext()){
								temp = (String) iterator.next();
								out.println("<option value=\"" + temp + "\">" + temp + "</option>");  
							}
							
						}else{
						%>
							<% if (month > 9){ %>
								 <option value="October">October</option> 
								 <option value="November">November</option> 
								 <option value="December">December</option>
							<%}else if(month > 6){ %>
								 <option value="July">July</option> 
								 <option value="August">August</option> 
								 <option value="September">September</option> 
							<%}else if(month > 3){ %>	
								 <option value="April">April</option> 
								 <option value="May">May</option> 
								 <option value="June">June</option> 
							<%}else{ %>
								 <option value="January">January</option> 
								 <option value="February">February</option>  
								 <option value="March">March</option> 
							<%}%>
						<%				
							}
						%>				
				</select>				
			</td>
 </tr>
<tr>
			<td style="text-align:left">
				Select Year:
				<select name="nomyear">

					<% 
						Query<BestOfSiteOptions> qq = ofy.query(BestOfSiteOptions.class).order("Year");
						if( qq.countAll() > 0 ){
							
							HashSet <String>hh = new HashSet <String>();
							Iterator iterator;
							String temp = "";							
							for ( BestOfSiteOptions f : qq.fetch() ) {
								hh.add(f.getYear());
							}
							
							iterator = hh.iterator(); 
							while (iterator.hasNext()){
								temp = (String) iterator.next();
								out.println("<option value=\"" + temp + "\">" + temp + "</option>");  
							}
							
						}else{					
							  int yearNow = cal.get(Calendar.YEAR);
							  int yearOld  = cal.get(Calendar.YEAR) -1;
						%>
							  <option value=<%= yearNow %>><%= yearNow %></option>
							  <option value=<%= yearOld %>><%= yearOld %></option>				  				  
						<% 	
							//out.println("<option value=\"" + sYear + "\">" + sYear + "</option>");
						}
					%>


				</select>				
				 
			</td>
		</tr>
<br/>
		<tr>
			<td style="text-align:left">
<span class="lotusBtn lotusBtnAction lotusLeft">
        <a href=javascript:addtoSCbasket(<%= request.getParameter("sol_id") %>)><b>Save</b></a>
</span>
			</td> 
		</tr>

		
	</tbody>
</table>

</form>

